package ig.util;
import java.awt.Component;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.table.TableCellRenderer;
import javax.swing.JTable;

/**
 */
public class RenderTabla extends JLabel implements TableCellRenderer{

   
   
   //ValueDocument vd= new ValueDocument("DOUBLE");
   
     public RenderTabla(JTable table){
        table.setDefaultRenderer (String.class, this);
        table.setDefaultRenderer (Double.class, this);         
        table.setDefaultRenderer (Integer.class, this);         
        setOpaque(true);
     }     

    public Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected, boolean hasFocus, int row, int column){
   	 RenderTabla etiqueta = new RenderTabla(table);         
//         if(isSelected){
//             etiqueta.setBackground(new java.awt.Color(191,206,237)); 
//         }else{
//             etiqueta.setBackground(new java.awt.Color(255, 255, 255));
//         }
         //table.getSelectedRow()
         etiqueta.setFont(new java.awt.Font("Dialog", 0, 12));             
         if (value instanceof String){
             //etiqueta.setFont(new java.awt.Font("Dialog", 0, 12));             
             etiqueta.setText((String)value);             
             etiqueta.setBackground(new Color(238,238,238));
             etiqueta.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);  
         }else if (value instanceof Double){
             if(isSelected)etiqueta.setBackground(new Color(204,204,255));
             else etiqueta.setBackground(new java.awt.Color(255, 255, 255));
             etiqueta.setText(((Double)value).toString());
             etiqueta.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
         }else if (value instanceof Integer){
             if(isSelected)etiqueta.setBackground(new Color(204,204,255));
                 etiqueta.setText(((Integer)value).toString());             
             if(row==column-1){
                 etiqueta.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
                 //etiqueta.setFont(new java.awt.Font("Dialog", 1, 12));                          
                 etiqueta.setBackground(new Color(204,255,204));
             }                 
         }         
//         System.out.println("sup");
         return etiqueta;
     }
    
 }